#ifndef _ESC_QUEUE_H_
#define _ESC_QUEUE_H_

/*
 * Essential-C - Essential C Libraries for Developers
 * Copyright (c) 2004-2008 Tom Bradford <tom@tbradford.org>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a 
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */

/**
 * Implements a simple queue based on the esc_list type.
 *
 * Note: These functions are NOT thread-safe.  You must manage
 * your own mutexes if you plan on safely threading a Queue or
 * Queue-derived structures.
 */

#include "esc_list.h"
#include "esc_mem.h"

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus


/** Incomplete type for Queue instances */
typedef esc_list_t esc_queue_t;

/** Create a Queue instance */
esc_queue_t* esc_queue_new(esc_mem_t* mem);

/** Add an item onto the Queue */
void esc_queue_add(esc_queue_t* queue, void* item);

/** Remove the next item from the Queue */
void* esc_queue_remove(esc_queue_t* queue);

/** Peek at the first item on the Queue */
void* esc_queue_peek(esc_queue_t* queue);

/** Removes all items from the Queue */
void esc_queue_removeAll(esc_queue_t* queue);

/** Returns the total number of items in the Queue */
int esc_queue_getSize(esc_queue_t* queue);

/** Returns whether or not the Queue is empty */
bool esc_queue_isEmpty(esc_queue_t* queue);


#ifdef __cplusplus
}
#endif // __cplusplus

#endif // _ESC_QUEUE_H_
